package com.example.demo.mapper;

import com.example.demo.entity.AdminLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AdminLogMapper {
    //根据管理员id查找登录日志信息
    @Select("select * from admin_log where admin_id = #{admin_id}")
    List<AdminLog> findByAdminId(Integer admin_id); // 根据管理员ID 查找登录日志

    //查询所有登录记录
    @Select("select * from admin_log")
    List<AdminLog> findAll(); //返回所有登录日志

    //根据登录日志id查询
    @Select("select * from admin_log where logID = #{logID}")
    AdminLog findByAdminLogId(Integer logId);

    @Insert("INSERT INTO admin_log(admin_id, name, Log_Content, IP_Address, OS, IE, CreateDate, Remark) " +
            "VALUES (#{admin_id},#{name},#{Log_Content}, #{IP_Address}, #{os}, #{browser}, #{CreateDate}, #{Remark})") // 改为 Java 属性名
    Integer addAdminLoginLogs(AdminLog adminLog); // 返回插入结果
}
